<html>
<head><meta charset="utf-8"><title>TransmuteOptions · project-safe-transmute · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/index.html">project-safe-transmute</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html">TransmuteOptions</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="217191076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191076">(Nov 18 2020 at 20:18)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> +1 to exposing variants as different traits.</p>



<a name="217191172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191172">(Nov 18 2020 at 20:19)</a>:</h4>
<p>I'd much rather have (insert naming bikeshed here) <code>NeglectedValidityUnsafeTransmuteFrom&lt;Src&gt;</code> as a blanket impl than have people publicly using <code>UnstableTransmuteFrom&lt;Src, ..., NeglectValidity&gt;</code>.</p>



<a name="217191325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191325">(Nov 18 2020 at 20:20)</a>:</h4>
<p>This implies 2³ different traits...</p>



<a name="217191377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191377">(Nov 18 2020 at 20:21)</a>:</h4>
<p>Only if every combination is something we want to expose.</p>



<a name="217191506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191506">(Nov 18 2020 at 20:22)</a>:</h4>
<p>Also, another approach would be (again, naming) <code>Dst: NeglectedEverythingUnsafeTransmuteFrom&lt;Src&gt;, Dst: AlignmentCheckedUnsafeTransmuteFrom&lt;Src&gt;</code>.</p>



<a name="217191539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191539">(Nov 18 2020 at 20:22)</a>:</h4>
<p>Traits that could be combined to specify multiple aspects.</p>



<a name="217191665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191665">(Nov 18 2020 at 20:23)</a>:</h4>
<p>The combinations we don't expose are cases where the only recourse for end-users is a <em>totally</em> unchecked transmutation.</p>



<a name="217191741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191741">(Nov 18 2020 at 20:24)</a>:</h4>
<p>Yes. And those are the combinations for which we aren't ready to expose a stable interface for safe transmutation. We don't have to solve all problems at once.</p>



<a name="217191775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191775">(Nov 18 2020 at 20:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/216762-project-safe-transmute/topic/UnstableTransmuteFrom/near/217191506">said</a>:</p>
<blockquote>
<p>Also, another approach would be (again, naming) <code>Dst: NeglectedEverythingUnsafeTransmuteFrom&lt;Src&gt;, Dst: AlignmentCheckedUnsafeTransmuteFrom&lt;Src&gt;</code>.</p>
</blockquote>
<p>I'm a little concerned that doing the right thing with this API (i.e., neglecting as few options as possible) takes <em>more</em> typing.</p>



<a name="217191813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191813">(Nov 18 2020 at 20:24)</a>:</h4>
<p>Fair point (also, extensibility to more things you might want to neglect).</p>



<a name="217191885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191885">(Nov 18 2020 at 20:25)</a>:</h4>
<p>That's a compelling argument for the negative direction rather than the positive.</p>



<a name="217191951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217191951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217191951">(Nov 18 2020 at 20:26)</a>:</h4>
<p>My concern at the moment is "how do we expose much less surface area".</p>



<a name="217192035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192035">(Nov 18 2020 at 20:26)</a>:</h4>
<p>The encoding using tuples of void types is pretty gross to me. I really hope we can get some const generics in here</p>



<a name="217192085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192085">(Nov 18 2020 at 20:26)</a>:</h4>
<p><code>Dst: TransmuteFrom&lt;Src&gt;</code> is very little surface area. <code>Options</code> and <code>Scope</code> feel like very large surface areas that I'd be hesitant to <em>ever</em> stabilize, especially <code>Scope</code>.</p>



<a name="217192131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192131">(Nov 18 2020 at 20:27)</a>:</h4>
<p>it's starting to remind me of C++ template metaprogramming</p>



<a name="217192174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192174">(Nov 18 2020 at 20:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/216762-project-safe-transmute/topic/UnstableTransmuteFrom/near/217192035">said</a>:</p>
<blockquote>
<p>The encoding using tuples of void types is pretty gross to me. I really hope we can get some const generics in here</p>
</blockquote>
<p>I've seen some libraries do this via types with a generic parameter: <code>NeglectFoo&lt;NeglectBar&lt;SomeBase&gt;&gt;</code>.</p>



<a name="217192182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192182">(Nov 18 2020 at 20:27)</a>:</h4>
<p>Several serde libraries do that for instance.</p>



<a name="217192200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192200">(Nov 18 2020 at 20:27)</a>:</h4>
<p>I'm sure, there isn't really an alternative right now</p>



<a name="217192204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192204">(Nov 18 2020 at 20:27)</a>:</h4>
<p>I'm going to roll these last few messages out into a separate topic, because they're not specific to <code>UnstableTransmuteFrom</code>.</p>



<a name="217192361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192361">(Nov 18 2020 at 20:29)</a>:</h4>
<p>Fair. Please feel free to ignore my previous comments on combinable "positive" traits, because the more I think about it, that <em>would</em> break future compatibility.</p>



<a name="217192408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192408">(Nov 18 2020 at 20:29)</a>:</h4>
<p>I'm still concerned about Scope and Options, but I do agree now that if we have Options then <code>Neglect</code> (modulo naming) is the right "polarity".</p>



<a name="217192440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192440">(Nov 18 2020 at 20:29)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> there are a few advantages to tuples of void types over const generics:</p>
<ul>
<li>transmute options are flags to a static analysis; they <em>never</em> make sense in the value domain</li>
<li>you can default type parameters, but not const generic parameters</li>
</ul>



<a name="217192523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192523">(Nov 18 2020 at 20:30)</a>:</h4>
<p>The latter seems fixable.</p>



<a name="217192598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192598">(Nov 18 2020 at 20:31)</a>:</h4>
<p>yeah my comment is really forward-thinking. Do what you have to to make it work on today's rust, but maybe it can be done better in the future</p>



<a name="217192667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217192667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217192667">(Nov 18 2020 at 20:31)</a>:</h4>
<p>Yeah, the syntax for tuple types and tuple values is identical, so in principle we might even be able to migrate to const generics in the future!</p>



<a name="217216863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217216863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217216863">(Nov 19 2020 at 00:47)</a>:</h4>
<p>My two cents: I prefer generics to the exponential combination of fully laid out trait names, especially since downstream users could always define their own alias for a specific tuple combination the use a lot.</p>
<p>Regarding the parameters themselves, something "interesting" since it would better convey that these are order-agnostic bags of (neglected) properties, would be to use phony trait objects with marker traits.</p>
<p>You can have a preview of that approach in a recent crate of mine: <a href="https://docs.rs/stackbox/0.1.0/stackbox/dyn_traits/any/index.html">https://docs.rs/stackbox/0.1.0/stackbox/dyn_traits/any/index.html</a></p>



<a name="217217088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217217088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217217088">(Nov 19 2020 at 00:50)</a>:</h4>
<p>(ignore the <code>dyn Any</code> part, and focus on my having used <code>dyn Send</code> and <code>dyn Sync</code> phony types instead of <code>enum IsSend {}</code>, <code>enum IsSync</code>), which allows combining them with <code>+</code> rather than <code>(,)</code> )</p>



<a name="217219916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217219916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217219916">(Nov 19 2020 at 01:35)</a>:</h4>
<p>Yeah, I'm holding out for anonymous union types. <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span> It should be <code>(NeglectAlignment | NeglectValidity)</code>, not <code>(NeglectAlignment, NeglectValidity)</code>.</p>
<p>Since <code>Options</code> is a type parameter, we're free to change the syntax in the future. (We can't eliminate the old one, but we can deprecate it.)</p>



<a name="217233238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217233238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217233238">(Nov 19 2020 at 06:15)</a>:</h4>
<p>I mean, ignoring what features currently exist I'd still expect <code>[Neglect::Alignment, Neglect::Validity]</code>.</p>



<a name="217421672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217421672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217421672">(Nov 20 2020 at 16:12)</a>:</h4>
<p>Tbh, the only thing needed to "hack" such union types is being able to disable the <code>bare_trait_objects</code> for specific types. Then we'd be able to write <code>NeglectAlignment + NeglectValidity</code></p>



<a name="217428292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217428292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217428292">(Nov 20 2020 at 16:54)</a>:</h4>
<p><span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span> That's a pretty neat idea.</p>



<a name="217432159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217432159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217432159">(Nov 20 2020 at 17:22)</a>:</h4>
<p><span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span> This is <em>great</em>!<br>
<a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=536c6498c1088279a03cdc9afc3c00fa">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=536c6498c1088279a03cdc9afc3c00fa</a></p>



<a name="217436013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217436013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217436013">(Nov 20 2020 at 17:52)</a>:</h4>
<p>Oh, I had forgotten that <code>auto trait</code> requirement <span aria-label="sob" class="emoji emoji-1f62d" role="img" title="sob">:sob:</span> when will the <code>#[marker_trait]</code>RFC  go forward?</p>



<a name="217439733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217439733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217439733">(Nov 20 2020 at 18:22)</a>:</h4>
<p>What's the connection to the <code>#[marker]</code> feature?</p>



<a name="217454622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217454622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217454622">(Nov 20 2020 at 20:25)</a>:</h4>
<p>Because those can't have overrides, and thus don't need anything (extra) in the vtable, it's possible that the check for "extra <code>+</code>ed traits" could move to looking for marker traits instead of auto traits.</p>



<a name="217454649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/217454649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#217454649">(Nov 20 2020 at 20:26)</a>:</h4>
<p>(Though there are some design questions there if the marker trait has non-marker-trait subtraits [or supertraits?  I never remember which direction is which])</p>



<a name="218133942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/218133942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#218133942">(Nov 27 2020 at 22:34)</a>:</h4>
<p>I've collated the various possibilities for representing a <code>Neglect</code> const/type parameter: <a href="https://hackmd.io/@jswrenn/S192QCR9D">https://hackmd.io/@jswrenn/S192QCR9D</a></p>
<p>Let me know if I've missed anything!</p>



<a name="218231080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/218231080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#218231080">(Nov 29 2020 at 21:18)</a>:</h4>
<p><span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span>  I <em>really</em> like the <code>Option + Option + ...</code> type parameter  approach, but it doesn't obviously admit any way to express <em>adding</em> an option to a generic set of options.</p>



<a name="218231082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/218231082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#218231082">(Nov 29 2020 at 21:18)</a>:</h4>
<p>For instance, <code>TransmuteFrom</code> is implemented for all <code>Src</code> and <code>Dst</code> that are <code>UnstableTransmuteFrom</code> and the appropriate <code>Muckable</code>s, <em>notwithstanding visibility</em>:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="n">Src</span><span class="p">,</span><span class="w"> </span><span class="n">Dst</span><span class="p">,</span><span class="w"> </span><span class="n">Neglect</span><span class="o">&gt;</span><span class="w"> </span><span class="n">TransmuteFrom</span><span class="o">&lt;</span><span class="n">Src</span><span class="p">,</span><span class="w"> </span><span class="n">Neglect</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Dst</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">Src</span>: <span class="nc">MuckableInto</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Dst</span>: <span class="nc">MuckableFrom</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Dst</span>: <span class="nc">UnstableTransmuteFrom</span><span class="o">&lt;</span><span class="n">Src</span><span class="p">,</span><span class="w"> </span><span class="o">!</span><span class="p">,</span><span class="w"> </span><span class="n">Neglect</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">NeglectVisibility</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Neglect</span>: <span class="nc">TransmuteOptions</span><span class="w"></span>
<span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="218231093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/218231093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#218231093">(Nov 29 2020 at 21:18)</a>:</h4>
<p>But you <em>can't</em> write <code>Neglect + NeglectVisibility</code>. That's a compile error.</p>



<a name="218231193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/218231193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#218231193">(Nov 29 2020 at 21:21)</a>:</h4>
<p>The alternative of a <code>const NEGLECT: Neglect</code> parameter handles this case really smoothly:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="n">Src</span><span class="p">,</span><span class="w"> </span><span class="n">Dst</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">NEGLECT</span>: <span class="nc">Neglect</span><span class="o">&gt;</span><span class="w"> </span><span class="n">TransmuteFrom</span><span class="o">&lt;</span><span class="n">Src</span><span class="p">,</span><span class="w"> </span><span class="n">NEGLECT</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Dst</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">Src</span>: <span class="nc">MuckableInto</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Dst</span>: <span class="nc">MuckableFrom</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Dst</span>: <span class="nc">UnstableTransmuteFrom</span><span class="o">&lt;</span><span class="n">Src</span><span class="p">,</span><span class="w"> </span><span class="o">!</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">visibility</span>: <span class="nc">true</span><span class="p">,</span><span class="w"> </span><span class="o">..</span><span class="n">NEGLECT</span><span class="p">}}</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Neglect</span>: <span class="nc">TransmuteOptions</span><span class="w"></span>
<span class="p">{}</span><span class="w"></span>
</code></pre></div>
<p>The syntax isn't <em>quite</em> as pretty, but we can get close with an <code>Add</code> impl on <code>Neglect</code>:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="n">Src</span><span class="p">,</span><span class="w"> </span><span class="n">Dst</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">NEGLECT</span>: <span class="nc">Neglect</span><span class="o">&gt;</span><span class="w"> </span><span class="n">TransmuteFrom</span><span class="o">&lt;</span><span class="n">Src</span><span class="p">,</span><span class="w"> </span><span class="n">NEGLECT</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Dst</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">Src</span>: <span class="nc">MuckableInto</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Dst</span>: <span class="nc">MuckableFrom</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Dst</span>: <span class="nc">UnstableTransmuteFrom</span><span class="o">&lt;</span><span class="n">Src</span><span class="p">,</span><span class="w"> </span><span class="o">!</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="n">NEGLECT</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">Neglect</span>::<span class="n">VISIBILITY</span><span class="p">}</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Neglect</span>: <span class="nc">TransmuteOptions</span><span class="w"></span>
<span class="p">{}</span><span class="w"></span>
</code></pre></div>
<p>The <em>only</em> major downside of this approach is you can't default const generic parameters, but that seems to me like a plausible future extension to const generics.</p>



<a name="218324854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/TransmuteOptions/near/218324854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/TransmuteOptions.html#218324854">(Nov 30 2020 at 18:22)</a>:</h4>
<p>Yeah, combining such types would be very cumbersome (involving helper traits): <code>&lt;Neglect as With&lt;NeglectVisibility&gt;&gt;::T</code> which hinders readability and, in practice, usually requires adding many <code>where Neglect : With&lt;NeglecVisibility&gt;</code> kind of bounds in many places, and it quickly spirals out of control / any real usability.<br>
So despite how "elegant" the autotraits "sums" looked, I think <code>const</code> generics are the way to go, indeed.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>